<?php
require_once "common.php";
class upload{
    //$name为上传控件的name值
    function imgUpload($name){
        echo "upload";
        var_dump($_FILES["$name"]["name"]);
            if ((($_FILES["$name"]["type"] == "image/gif")
                ||($_FILES["$name"]["type"] == "image/jpeg")
                ||($_FILES["$name"]["type"] == "image/pjpeg"))
                &&($_FILES["$name"]["size"])<2000000)
                {
                    
                    echo "upload11";
                    echo $_FILES["$name"]["error"];
                    if ($_FILES["$name"]["error"]>0){
                            echo $_FILES["img"]["error"];
                        }
                    if (file_exists("upload/".$_FILES["$name"]["name"])){
                        echo "rename";
                        
                        }else{
                            echo "move";
                               $res= move_uploaded_file($_FILES["$name"]["tmp_name"],"upload/".$_FILES["$name"]["name"]);
                               var_dump($res);
                            
                            }
                    }
        }
    
    
    
    }
?>
<html>
<form method="post" enctype="multipart/form-data">
<input type="file" name="img" id="img" />
<input type="submit" name="submit" value="submit" />

</form>
</html>
<?php
$img= new upload();
$img->imgUpload("img");

?>
